using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Collections.ObjectModel;
using System.Xml.Serialization;
using EnvDTE;
using Microsoft.VisualStudio.Shell.Interop;
using System.Diagnostics;
using System.IO;
using System.Security.Cryptography;
using System.Windows;
using System.Windows.Input;
using System.Threading;
using System.Windows.Threading;
using System.Net;
using System.Threading.Tasks;

namespace WebAppUploader
{
	public class ActionCommand<T> : ICommand
	{

		Action<T> action = null;

		Func<T,bool> _canExecute = null;

		public ActionCommand(Action<T> action, Func<T,bool> canExecute = null)
		{
			this.action = action;
			if (canExecute == null)
				canExecute = x => true;
			_canExecute = canExecute;
		}

		#region public bool  CanExecute(object parameter)
		public bool CanExecute(object parameter)
		{
			return _canExecute((T)parameter);
		}
		#endregion


		public event EventHandler CanExecuteChanged;

		#region public void  Execute(object parameter)
		public void Execute(object parameter)
		{
			action((T)parameter);
		}
		#endregion

	}

	
}
